package com.hub.grpc.server.service;


import com.hub.grpc.proto.UserRequest;
import com.hub.grpc.proto.UserResponse;
import com.hub.grpc.proto.UserServiceGrpc;
import com.hub.grpc.server.annotation.GrpcService;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;

/**
 * @ author 飞天蝙蝠
 * @ date & time 2024/12/30 15:59
 */
@Slf4j
@GrpcService
public class UserService extends UserServiceGrpc.UserServiceImplBase {

    @Override
    public void query(UserRequest request, StreamObserver<UserResponse> responseObserver) {
        log.info("Received request: {}", request);
        responseObserver.onNext(UserResponse.newBuilder().setName(request.getName()).setAge(18).setAddress("南京市秦淮区通服大厦21F").build());
        responseObserver.onCompleted();
    }
}
